import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Item {
    id: extraShortBack_ManualProcess
    width: 1760
    height: 630

    Component.onCompleted: {
        Cpp_PLC.read_ExtraShort_Process_Hold();
        Cpp_PLC.write_into_PLC_16_Hold(48,"5")
    }

    A_NumberKeyboard{
        id: extraShortProcessKeyboard
        isDirectOverwrite: false
    }

    property real fontSize: Cpp_Language.CurrentLanguage === 1 ? 40 : Cpp_Language.CurrentLanguage === 2 ? 25 : Cpp_Language.CurrentLanguage === 3 ? 25 : 40

    Column{
        anchors.horizontalCenter: extraShortBack_ManualProcess.horizontalCenter
        anchors.top: extraShortBack_ManualProcess.top
        anchors.topMargin: 20
        spacing: 10


        Item{
            width: 1200
            height: 90
            visible: !Cpp_PLC.M_394

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("料  高")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                inputWidth: 300
                inputHeight: 80
                keyboard: extraShortProcessKeyboard
                text: Cpp_PLC.MaterialHeight_NormalProcess

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(214,value)
                }
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("超 短 料 长")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                inputWidth: 300
                inputHeight: 80
                maxValue: Cpp_PLC.ExtraShort_Max
                minValue: Cpp_PLC.ExtraShort_Min
                keyboard: extraShortProcessKeyboard
                text: Cpp_PLC.ExtraShort_MaterialLength

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(224,value)
                }
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("超 短 补 偿")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                inputWidth: 300
                inputHeight: 80
                keyboard: extraShortProcessKeyboard
                text: Cpp_PLC.ExtraShort_Compensate

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(1380,value)
                }
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("回 拉 距 离")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                inputWidth: 300
                inputHeight: 80
                keyboard: extraShortProcessKeyboard
                text: Cpp_PLC.Pull_Back_Distance

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(1390,value)
                }
            }

        }
        Item{
            width: 1200
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("当 前 段 数")
                }

            }

            Rectangle{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                width: 300
                height: 80
                border.width: 3
                radius: 5
                border.color: "white"
                color: "black"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    color: "white"
                    text: Cpp_PLC.CurrentCutSegments_NormalProcess
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 800
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: qsTr("清  空")
                // isSelected: Cpp_PLC.M_240

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(75,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(75,false)
            }

        }

    }


    Rectangle{
        width: 1200
        height: 1
        color: "black"
        anchors.horizontalCenter: extraShortBack_ManualProcess.horizontalCenter
        anchors.bottom: extraShortBack_ManualProcess.bottom
        anchors.bottomMargin: 100
    }

    Rectangle{      // 超短加工 - 手动操作按钮
        anchors.horizontalCenter: extraShortBack_ManualProcess.horizontalCenter
        anchors.bottom: extraShortBack_ManualProcess.bottom
        anchors.bottomMargin: 10
        width: 1750
        height: 80
        color: "transparent"

        Row{
            anchors.centerIn: parent
            spacing: 30

            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: Cpp_PLC.M_240 ? qsTr("锯 启") : qsTr("锯 停")
                isSelected: Cpp_PLC.M_240

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(237,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(237,false)
            }

            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("压 紧")
                isSelected: Cpp_PLC.M_239

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(236,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(236,false)

            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("锯 切")

                isSelected: Cpp_PLC.M_241

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(238,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(238,false)

            }

            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("复 位")

                // isSelected: Cpp_PLC.M_240

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(5,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(5,false)
            }            



        }
    }

}
